using UnityEngine;

[CreateAssetMenu(menuName = "RPG Setup/Item Data/ItemEffect/SwordToRecoverHealth", fileName = "Item effect data - SwordToRecoverHealth ")]
public class ItemEffect_SwordToRecoverHealth : ItemEffect_DataSO
{
    [SerializeField] private float damagePercentRecover = .2f;
    public override void ApplyEffect()
    {

    }

    public void RecoverHealth(float damage)
    {
        float recoverHealthPercent = damage * damagePercentRecover;
        player.playerHealth.IncreaseHealth(recoverHealthPercent);
    }
    public override void Subscribe(Player player)
    {
        base.Subscribe(player);
        player.entityCombat.OnDoingPhysicalDamage += RecoverHealth;
    }
    public override void UnSubscribe()
    {
        player.entityCombat.OnDoingPhysicalDamage -= RecoverHealth;
        player = null;
    }
}
